<?php

namespace app\beautiful\model\member;

use app\beautiful\model\CouponModel;
use app\beautiful\model\logs\MemberCouponLogsModel;
use app\common\model\CommonModel;



class MemberCouponModel extends CommonModel{

    protected  $name = 'beautiful_member_coupon';

    protected  $pk   = 'member_coupon_id';



    public function getIsExpireAttr($value,$data)

    {

        return $data['valid_end_time']<date("Y-m-d") ? 1 : 0;

    }

    public function coupon()

    {

        return $this->belongsTo(CommonModel::class,'coupon_id','coupon_id');

    }
    public function couponLogs()

    {

        return $this->belongsTo(MemberCouponLogsModel::class,'member_coupon_id','member_coupon_id');

    }
    public function couponInfo(){

        return  $this->hasOne(CouponModel::class,'coupon_id','coupon_id');

    }
}

